<?php
	session_start();
	require_once('functions.php');
	
	if( $_SESSION['account_type_code'] != 1 ) 
	{
		header("Location:index.php?response_msg=Please login.");
		exit;
	}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Admin</title>
</head>

<body>
	<h1>WELCOME ADMIN</h1> <a href="signout.php">(Signout)</a>
	<h2 style="color:red">
		<?php
			if($_REQUEST['response_msg']) 
			{
				echo htmlspecialchars($_REQUEST['response_msg']);
				$_REQUEST['response_msg'] = '';
			}
		?>
	</h2>
	<hr/>
	<h2>Add new boat:</h2>
	
	<form method="post" action="add_new_boat.php">
		<label for="boat_name">Boat Name: </label>
		<input type="text" name="boat_name" value=""><br/>
		
		<label for="boat_color">Boat Color: </label>
		<input type="text" name="boat_color" value=""><br/>
		
		<input type="reset" name="" value="Reset">
		<input type="submit" name="" value="Add">
	</form>
	
	<hr/>
	<h2>Modify/delete boats:</h2>
	
	<?php
		$boat_list = get_boat_list();
	?>	
		<input type="text" name="" value="Boat Name" disabled="disabled">
		<input type="text" name="" value="Boat Color" disabled="disabled">
		<input type="text" name="" value="Actions" disabled="disabled">
		<br/>
	<?php	
		foreach($boat_list as $boat)
		{
	?>
				
				<form method="post" action="update_boat.php" style="display:inline;">
					<input type="text" name="boat_name" value="<?php echo $boat['bname'] ?>" >
					<input type="text" name="boat_color" value="<?php echo $boat['color'] ?>" >
					<input type="hidden" name="boat_id" value="<?php echo $boat['bid'] ?>" >
					<input type="submit" name="" value="Modify">
				</form>
				
				<form method="post" action="delete_boat.php" style="display:inline;" onsubmit="return confirm('Are you sure you want to delete this boat?');">
					<input type="hidden" name="boat_id" value="<?php echo $boat['bid'] ?>" >
					<input type="submit" name="" value="Delete">
				</form>
				
				<br/>


	<?php
		}
	?>
	
</body>
</html>
